import {
    fetchPaymentItems,
    fetchPaymentItemConfig,
    remove,
    add
  } from "@/api/paymentItem"
import { edit } from "../../../api/paymentItem"
  export default {
    namespaced: true, // 封闭
    state: {},
    mutations: {},
    getters: {},
    actions: {
      async fetchPaymentItems(context) {
        try {
          return await fetchPaymentItems()
        } catch (err) {
          console.log(err)
        }
      },

      async fetchPaymentItemConfig(context){
        try {
          return await fetchPaymentItemConfig()
        } catch (err) {
          console.log(err)
        }
      },

      async remove(context, id){
        try {
          return await remove(id)
        } catch (err) {
          console.log(err)
        }
      },

      async add(context, data) {
        try{
          let { payTypeName, price, unit, paymentTimeType, paymentTimeTypeName, timePos, day, months } = data
          return await add(payTypeName, price, unit, paymentTimeType, paymentTimeTypeName, timePos, day, months)
        } catch(err){
          console.log('err', err)
        }
      },

      async edit(context, data) {
        try{
          let { payTypeId, price, unit, paymentTimeType, paymentTimeTypeName, timePos, day, months } = data
          return await edit(payTypeId, price, unit, paymentTimeType, paymentTimeTypeName, timePos, day, months)
        } catch(err){
          console.log('err', err)
        }
      }
    }
  }
  